Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /*jslint |
||
271 | Markers.createMarkerDiv = function (id) { |
||
272 | 'use strict'; |
||
273 | |||
274 | var iconw = 33, |
||
275 | iconh = 37, |
||
276 | offsetx = (id % 26) * iconw, |
||
277 | offsety = Math.floor(id / 26) * iconh; |
||
278 | |||
279 | return "<div id=\"dyn" + id + "\">" + |
||
280 | "<table class=\"view\" style=\"width: 100%; vertical-align: middle;\">\n" + |
||
281 | " <tr>\n" + |
||
282 | " <td rowspan=\"3\" style=\"vertical-align: top\">\n" + |
||
283 | " <span style=\"width:" + iconw + "px; height:" + iconh + "px; float: left; display: block; background-image: url(img/markers.png); background-repeat: no-repeat; background-position: -" + offsetx + "px -" + offsety + "px;\"> </span>\n" + |
||
284 | " </td>\n" + |
||
285 | " <td style=\"text-align: center\"><i class=\"fa fa-map-marker\"></i></td>\n" + |
||
286 | " <td class=\"name\" colspan=\"2\">marker</td>\n" + |
||
287 | " </tr>\n" + |
||
288 | " <tr>\n" + |
||
289 | " <td style=\"text-align: center\"><i class=\"fa fa-globe\"></i></td>\n" + |
||
290 | " <td class=\"coords\" colspan=\"2\">N 48° 00.123 E 007° 51.456</td>\n" + |
||
291 | " </tr>\n" + |
||
292 | " <tr>\n" + |
||
293 | " <td style=\"text-align: center\"><i class=\"fa fa-circle-o\"></i></td>\n" + |
||
294 | " <td class=\"radius\">16100 m</td>\n" + |
||
295 | " <td>\n" + |
||
296 | " <div class=\"btn-group\" style=\"padding-bottom: 2px; padding-top: 2px; float: right\">\n" + |
||
297 | " <button class=\"my-button btn btn-mini btn-warning\" data-i18n=\"[title]sidebar.markers.edit_marker\" type=\"button\" onclick=\"Markers.enterEditMode(" + id + ");\"><i class=\"fa fa-edit\"></i></button>\n" + |
||
298 | " <button class=\"my-button btn btn-mini btn-danger\" data-i18n=\"[title]sidebar.markers.delete_marker\" type=\"button\" onClick=\"Markers.removeById(" + id + ");\"><i class=\"fa fa-trash-o\"></i></button>\n" + |
||
299 | " <button class=\"my-button btn btn-mini btn-info\" data-i18n=\"[title]sidebar.markers.move_to\" type=\"button\" onClick=\"Markers.goto(" + id + ");\"><i class=\"fa fa-search\"></i></button>\n" + |
||
300 | " <button class=\"my-button btn btn-mini btn-warning\" data-i18n=\"[title]sidebar.markers.center\" type=\"button\" onClick=\"Markers.center(" + id + ");\"><i class=\"fa fa-crosshairs\"></i></button>\n" + |
||
301 | " <button class=\"my-button btn btn-mini btn-success\" data-i18n=\"[title]sidebar.markers.project\" type=\"button\" onClick=\"projectFromMarker(" + id + ");\"><i class=\"fa fa-location-arrow\"></i></button>\n" + |
||
302 | " </div>\n" + |
||
303 | " </td>\n" + |
||
304 | " </tr>\n" + |
||
305 | "</table>\n" + |
||
306 | "<table class=\"edit\" style=\"display: none; width: 100%; vertical-align: middle;\">\n" + |
||
307 | " <tr>\n" + |
||
308 | " <td rowspan=\"4\" style=\"vertical-align: top\"><span style=\"width:" + iconw + "px; height:" + iconh + "px; float: left; display: block; background-image: url(img/markers.png); background-repeat: no-repeat; background-position: -" + offsetx + "px -" + offsety + "px;\"> </span>\n" + |
||
309 | " <td style=\"text-align: center; vertical-align: middle;\"><i class=\"icon-map-marker\"></i></td>\n" + |
||
310 | " <td><input data-i18n=\"[title]sidebar.markers.name;[placeholder]sidebar.markers.name_placeholder\" class=\"name form-control input-block-level\" type=\"text\" style=\"margin-bottom: 0px;\" value=\"n/a\" /></td>\n" + |
||
311 | " </tr>\n" + |
||
312 | " <tr>\n" + |
||
313 | " <td style=\"text-align: center; vertical-align: middle;\"><i class=\"icon-globe\"></i></td>\n" + |
||
314 | " <td><input data-i18n=\"[title]sidebar.markers.coordinates;[placeholder]sidebar.markers.coordinates_placeholder\" class=\"coords form-control input-block-level\" type=\"text\" style=\"margin-bottom: 0px;\" value=\"n/a\" /></td>\n" + |
||
315 | " </tr>\n" + |
||
316 | " <tr>\n" + |
||
317 | " <td style=\"text-align: center; vertical-align: middle;\"><i class=\"icon-circle-blank\"></i></td>\n" + |
||
318 | " <td><input data-i18n=\"[title]sidebar.markers.radius;[placeholder]sidebar.markers.radius_placeholder\" class=\"radius form-control input-block-level\" type=\"text\" style=\"margin-bottom: 0px;\" value=\"n/a\" /></td>\n" + |
||
319 | " </tr>\n" + |
||
320 | " <tr>\n" + |
||
321 | " <td colspan=\"2\" style=\"text-align: right\">\n" + |
||
322 | " <button class=\"btn btn-small btn-primary\" type=\"button\" onclick=\"Markers.leaveEditMode(" + id + ", true);\" data-i18n=\"dialog.ok\">OK</button>\n" + |
||
323 | " <button class=\"btn btn-small\" type=\"button\" onclick=\"Markers.leaveEditMode(" + id + ", false);\" data-i18n=\"dialog.cancel\">CANCEL</button>\n" + |
||
324 | " </td>\n" + |
||
325 | " </tr>\n" + |
||
326 | "</table>" + |
||
327 | "</div>"; |
||
328 | }; |
||
329 | |||
384 |